package com.sk.sqd.context;

import com.sk.sqd.strategy.CashStrategy;
import com.sk.sqd.strategy.CashNormalStrategy;
import com.sk.sqd.strategy.CashRebateStrategy;
import com.sk.sqd.strategy.CashReturnStrategy;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 现金策略决策,根据策略类型获取不同策略
 */
@Component
public class CashStrategyDecider {

    @Resource
    private CashNormalStrategy normalStrategy;
    @Resource
    private CashRebateStrategy rebateStrategy;
    @Resource
    private CashReturnStrategy returnStrategy;

    public CashStrategy decideCashStrategy(String strategyType) {
        if (strategyType == null ) {
            return normalStrategy;
        }
        if (strategyType.equals(rebateStrategy.type())) {
            return rebateStrategy;
        } else {
            // todo 扩展点
            if (strategyType.equals(returnStrategy.type())) {
                return returnStrategy;
            }
        }
        return normalStrategy;
    }
}
